package cn.cqie.frame.enums;

import cn.cqie.frame.utils.AssertUtil;
import lombok.Getter;

import java.util.Arrays;

/**
 * @Author: XYH
 * @Description: 真假枚举
 * @Date: 09:49 2021/5/4
 * @Modified By:
 **/
@Getter
public enum YesOrNo {

    NO("0", "否/停用"), YES("1", "是/启用"),;

    private final String code;
    private final String desc;

    YesOrNo(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static YesOrNo getByCode(String code) {
        AssertUtil.isNotBlank(code, "枚举参数错误");
        YesOrNo[] values = values();
        return Arrays.stream(values).filter(it -> it.code.equals(code)).findAny().orElseGet(null);
    }

}
